﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleData.ObjectModel.Collections;
using System.Diagnostics.Contracts;

namespace SimpleData.ObjectModel
{
	/// <summary>
	/// Representa um documento do sistema
	/// </summary>
	public class Document
	{
		private DocumentValuesDictionary values;

		public Document( SchemaName schema )
			: this( schema, DocumentToken.NewToken() )
		{ }

		public Document( SchemaName schema, long oid )
			: this( schema, DocumentToken.NewToken( oid ) )
		{ }

		public Document( SchemaName schema, DocumentToken token )
		{
			Contract.Requires<ArgumentNullException>( schema != null );
			Contract.Requires<ArgumentNullException>( token != null );

			this.Schema = schema;
			this.Token = token;
			this.values = new DocumentValuesDictionary( new NamespaceScope( schema.Namespace ) );
		}

		/// <summary>
		/// 
		/// </summary>
		public DocumentToken Token
		{
			get;
			private set;
		}

		/// <summary>
		/// Define o schema do documento atual
		/// </summary>
		public SchemaName Schema
		{
			get;
			private set;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <returns></returns>
		//public object this[ string name ]
		//{
		//    get { return this.values[ name ]; }
		//    set { this.values[ name ] = value; }
		//}

		///// <summary>
		///// 
		///// </summary>
		///// <param name="name"></param>
		///// <returns></returns>
		//public object this[ FieldName name ]
		//{
		//    get { return this.values[ name ]; }
		//    set { this.values[ name ] = value; }
		//}

		/// <summary>
		/// 
		/// </summary>
		public DateTime? CreateStamp
		{
			get;
			internal set;
		}

		public DocumentValuesDictionary Values
		{
			get { return this.values; }
		}
	}
}
